package com.open.capacity.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.open.capacity.common.model.SttMenu;
import com.open.capacity.common.model.SysMenu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
* @author 作者 owen 
* @version 创建时间：2017年11月13日 上午22:57:51
 * 菜单
 */
@Component
public interface SysMenuDao extends BaseMapper<SttMenu> {

	@Insert("insert into stt_menu(parent, mename, menurl, mepath, mencss, mesort,ismenu,ishide) "
			+ "values (#{parentId}, #{name}, #{url} , #{path} , #{css}, #{sort},#{isMenu},#{hidden})")
	int save(SttMenu menu);

	
	@Delete("delete from stt_menu where menuid = #{id}")
	int deleteByPrimaryKey(Long id);

	@Delete("delete from stt_menu where parent = #{id}")
	int deleteByParentId(Long id);
	
	int updateByPrimaryKey(SttMenu menu);

	@Select("select menuid id,parent parentId, mename name, menurl url, mepath path, mencss css, mesort sort,ismenu isMenu,ishide hidden, crtime createTime,uptime updateTime from stt_menu t where t.menuid = #{id}")
	SttMenu findById(Long id);
	
	int count(Map<String, Object> params);
	
	List<SttMenu> findList(Map<String, Object> params);
	
	
	
}
